## DESCRIPTION
## Vector Calculus: graph of a 2D vector field
## ENDDESCRIPTION

## KEYWORDS('vector calculus', 'vector field graph 2D')

## DBsubject('WeBWorK')
## DBchapter('WeBWorK Tutorial')
## DBsection('Fort Lewis Tutorial 2011')
## Date('01/30/2011')
## Author('Paul Pearson')
## Institution('Fort Lewis College')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')


##############################
#  Initialization

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGgraphmacros.pl",
"VectorField2D.pl",
);

TEXT(beginproblem());

$refreshCachedImages = 1;


#############################
#  Setup

Context()->variables->add(y=>"Real");

#
#  Create a graph canvas
#
$gr = init_graph(-5,-5,5,5,grid=>[10,10],axes=>[0,0],pixels=>[400,400]);
$gr->lb('reset');
foreach my $j (1..4) {
  $gr->lb( new Label(-4.7,  $j, $j,'black','center','middle'));
  $gr->lb( new Label(-4.7, -$j,-$j,'black','center','middle'));
  $gr->lb( new Label(  $j,-4.7, $j,'black','center','middle'));
  $gr->lb( new Label( -$j,-4.7,-$j,'black','center','middle'));
}
$gr->lb( new Label(4.7,0.2,'x','black','center','middle'));
$gr->lb( new Label(0.2,4.7,'y','black','center','middle'));


VectorField2D(
graphobject => $gr,
Fx => Formula("x/(x^2+y^2)"),
Fy => Formula("y/(x^2+y^2)"),
xvar => "x",
yvar => "y",
xmin => -5,
xmax =>  5,
ymin => -5,
ymax =>  5,
xsamples => 10,
ysamples => 10,
vectorcolor => "blue",
vectorscale => 1.5,
vectorthickness => 2,
xavoid=>0,
yavoid=>0,
);


#############################
#  Main text

Context()->texStrings;
BEGIN_TEXT
This is a velocity vector field for an explosion at the origin 
that decreases in speed the farther the distance is from the origin.
$PAR
$BCENTER
\{ image(insertGraph($gr),width=>400,height=>400,tex_size=>700) \}
$ECENTER
END_TEXT
Context()->normalStrings;


############################
#  Answers

$showPartialCorrectAnswers = 1;


############################
#  Solution

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT("MathObject version.");

ENDDOCUMENT();

